import Vue from 'vue'
import Vuex from 'vuex'
import matrixData from '../api/matrixqueData'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    basicIndex: {
      learn: 0,
      experience: 0,
      health: 0,
      burnout: 0,
      // anxious: 0,
      pressure: 0,
      ability: 0,
      // ba: 0,
      pa: 0,
      ea: 0,
      sa: 0,
      pb: 0,
      influence: 0,
      oi: 0,
      pi: 0,
      si: 0
    },
    avgIndex: {
      learn: 0,
      experience: 0,
      health: 0,
      burnout: 0,
      // anxious: 0,
      pressure: 0,
      ability: 0,
      // ba: 0,
      pa: 0,
      ea: 0,
      sa: 0,
      pb: 0,
      influence: 0,
      oi: 0,
      pi: 0,
      si: 0
    },
    stdIndex: {
      learn: 0,
      experience: 0,
      health: 0,
      burnout: 0,
      // anxious: 0,
      pressure: 0,
      ability: 0,
      // ba: 0,
      pa: 0,
      ea: 0,
      sa: 0,
      pb: 0,
      influence: 0,
      oi: 0,
      pi: 0,
      si: 0
    },
    form: [],
    matrixData: matrixData,
    timeCount: 0
  },
  getters: {
    getBasicIndex (state) {
      return state.basicIndex
    },
    getAvgIndex (state) {
      return state.avgIndex
    },
    getStdIndex (state) {
      return state.stdIndex
    },
    getForm (state) {
      return state.form
    },
    getMatrixData (state) {
      return state.matrixData
    },
    getTimeCount (state) {
      return state.timeCount
    }
  },
  mutations: {
    setBasicIndex (state, index) {
      Object.keys(index).forEach(key => {
        state.basicIndex[key] = index[key]
      })
    },
    setStdIndex (state, index) {
      Object.keys(index).forEach(key => {
        state.stdIndex[key] = index[key]
      })
    },
    setAvgIndex (state, index) {
      Object.keys(index).forEach(key => {
        state.avgIndex[key] = index[key]
      })
    },
    setForm (state, form) {
      state.form = []
      state.form = [...form]
    },
    setMatrixData (state, matrixData) {
      state.matrixData = JSON.parse(JSON.stringify(matrixData))
    },
    setTimeCount (state, timeCount) {
      state.timeCount = timeCount
    }
  },
  actions: {

  },
  modules: {
  }
})
